﻿using System;
using System.Timers;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace ActPPTimer.demo
{
    [Activity(Label = "ActPPTimer.demo", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
    {
        int count = 1;
        private Timer timer;
        private int mc = 0;
        private tdemo tttdemo;
        private TextView txtShow;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            txtShow = FindViewById<TextView>(Resource.Id.txtShow);

            button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };

            tttdemo=new tdemo();
            tttdemo.TimerShot += new EventHandler(tttdemo_TimerShot);
            timer = new Timer(1000);
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();
        }

        void tttdemo_TimerShot(object sender, EventArgs e)
        {
            mc++;
        }

        void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            tttdemo.RefreshTime();
        }

        protected override void OnResume()
        {
            txtShow.Text = mc.ToString();
            base.OnResume();
        }
    }
}

